package com.ming.yourdiary.view;

import android.graphics.Rect;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.ming.yourdiary.R;
import com.ming.yourdiary.util.UiTools;

public class DiaryNoteDecoration extends RecyclerView.ItemDecoration {

  private int itemHorizontalSpace = UiTools.getDimensionPixelOffset(R.dimen.dp_5);
  private int itemVerticalSpace = UiTools.getDimensionPixelOffset(R.dimen.dp_5);

  public DiaryNoteDecoration(int horizontalSpace, int verticalSpace) {
    if (horizontalSpace != 0) itemHorizontalSpace = horizontalSpace;
    if (verticalSpace != 0) itemVerticalSpace = verticalSpace;
  }

  @Override
  public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
    super.getItemOffsets(outRect, view, parent, state);
    outRect.set(itemHorizontalSpace, itemVerticalSpace, itemHorizontalSpace, itemVerticalSpace);
  }
}
